﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OperaHouse.Domain.Users;
using OperaHouse.Business.Users;

namespace OperaHouse.Web.Areas.Admin.Controllers
{
    public class BaseController : Controller
    {
        private User currentUser;

        public User CurrentUser
        {
            get { return currentUser; }
        }

        public BaseController()
        {
            if (System.Web.HttpContext.Current.User != null &&
                System.Web.HttpContext.Current.User.Identity != null &&
                System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                int currentUserId = int.Parse(System.Web.HttpContext.Current.User.Identity.Name);
                IUserService userService = DependencyResolver.Current.GetService<IUserService>();
                currentUser = userService.GetUserById(currentUserId);

                ViewBag.CurrentUser = currentUser;
            }
        }

    }
}
